﻿/*                              
   Copyright 2011 Nils Kopal, Christopher Krüger, Simone Sauer, Dennis Nolte, Uni Duisburg-Essen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
using System;

namespace Sharebert.DownloadLibrary.Interfaces
{
    /// <summary>
    /// A DownloadListener waits for download requests by DownloadClients
    /// </summary>
    public interface IDownloadListener
    {        
        /// <summary>
        /// Start listening for download requests
        /// </summary>
        void Start();

        /// <summary>
        /// Stop listening for download requests / stop handling actual downloads
        /// </summary>
        void Stop();

        /// <summary>
        /// Is this DownloadListener currently listening for download requests or not
        /// </summary>
        /// <returns></returns>
        bool IsRunning();

        /// <summary>
        /// The read/write timeout for the network communication
        /// </summary>
        int Timeout { get; set; }

        /// <summary>
        /// The port of this download listener on which it is listening for download requests
        /// </summary>
        int ListenPort { get; }

        /// <summary>
        /// Fired if a new file request occurs
        /// </summary>
        event EventHandler<FileRequestEventArgs> FileRequestReceived;

        /// <summary>
        /// Fired if an error occured
        /// </summary>
        event EventHandler<ErrorArgs> ErrorOccured;

        /// <summary>
        /// Fired each time a download starts or stops and contains the actual number of downloads
        /// </summary>
        event EventHandler<DownloadersArgs> DownloadersChanged;
    }
}
